package com.yimils.core.sys.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.yimils.core.common.dto.GetQueryParams;
import com.yimils.core.sys.dto.DeptDto;
import com.yimils.core.sys.dto.ReqAddDept;
import com.yimils.core.sys.entity.DeptEntity;
import com.yimils.core.sys.mapper.DeptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("deptService")
public class DeptServiceImpl extends ServiceImpl<DeptMapper, DeptEntity> implements DeptService {
    @Autowired
    private DeptDto deptDto;

    @Override
    public boolean createDept(ReqAddDept reqParams) {
        DeptEntity entity = deptDto.reqToEntity(reqParams);
        return save(entity);
    }

    @Override
    public List<DeptEntity> getList(GetQueryParams reqParams) {
        /*if (reqParams.getType() != null && reqParams.getType().equals(1)) {
            QueryWrapper<DeptEntity> qw = new QueryWrapper<>();
            qw.lambda().isNull(DeptEntity::getParentId).orderByAsc(DeptEntity::getSort);
            return list(qw);
        }*/
        return list();
    }
}
